define([ "jquery","comm","glable_mask","site_tip","files/flashChecker","mustache.min","text!/static/page/copy_share.html",
"enplaceholder","plugin/qtip/jquery.qtip.min","css!/static/js/jquery/qtip/jquery.qtip.css"],
		function($,comm,Glable_mask,Site_tip,FlashChecker,Mustache,tmpl) {
	var fls= new FlashChecker();
	var site_tip = new Site_tip();
	//require([],function(){});
	
	function Copy_share(){
		this.uuidArr = null;
		this.name = null;
		this.glable_mask = null;
		this.triggerBtn = false;
		this.addProcess=null;
	}

	/**
	 * 显示ui
	 * @param uuidArr 文件和文件夹的uuid
	 */
	Copy_share.prototype.showUI = function (uuidArr,name){
		var that = this;
		this.uuidArr = uuidArr;
		this.name = name;

        //检测是否存在文件
		/*this.checkFile(function(res){
			that.load_tpl();
		});*/
		that.load_tpl();
	}

    Copy_share.prototype.checkFile = function (cb) {
        var that = this;
        if (! this.uuidArr) return false;
        //var result = false;
		/*if(!that.glable_mask)
		{
			that.glable_mask = new Glable_mask();
		}*/
        /*$.ajax({
            url:"/share/check_file",
            type:"POST",
            data: {'data':this.uuidArr},
            dataType: "json",
            //async: false,
            success: function(res){
                if (res.ret == -1) {
                    //result = true
					if($.isFunction(cb))
					{
						cb(res);
					}
                } else {
                    var site_tip = new Site_tip();
                    site_tip.setContent(res.error,false,true);
                }
            }
        });*/
        //return result;
    }

	Copy_share.prototype.bindBtnDisable = function(){
		var that = this;
		if(that.triggerBtn)
		{
			//console.log(comm);
			comm.bindDisableHandler(that.triggerBtn);
		}
	}
	Copy_share.prototype.unbindBtnDisable = function(){
		var that = this;
		if(that.triggerBtn)
		{
			that.triggerBtn.attr("disabled",null);
		}
	}

	Copy_share.prototype.load_tpl = function (){
		var that = this;
		if(that.uuidArr.length<=0)
		{
			//var site_tip = new Site_tip();
			site_tip.setContent("请选择要分享的文件",false,true);
			return;
		}
		var getDataAjaxProcess;
		//that.bindBtnDisable();
		//$.get('/static/page/copy_share.html', function(tmpl) {
		if(!that.glable_mask)
		{
			that.glable_mask = new Glable_mask();
		}
		that.glable_mask.add($('<div class="copy_share" id="copy_share"><div class="panel"><div class="title">分享 <button class="close" type="button">×</button> </div> <div class="content"></div></div></div>'),true,function(){
			if(getDataAjaxProcess)
			{
				getDataAjaxProcess.abort();
			}
		});
		that.glable_mask.addLoadingView();
		getDataAjaxProcess=$.ajax({
			method:"post",
			url:"/share/to_share",
			data:{uuid: that.uuidArr,name:that.name},
			dataType:'json',
			success:function(data){
				if(data.success)
				{
					//that.glable_mask.removeLoadingView();
					//$("#copy_share").remove();
					//that.unbindBtnDisable();
					that.glable_mask.remove();
					//var tmpl = data.tmp;
					var sl_uuid = data.share_code;
					//var sl_uuid = comm.NewGuid();
					var link = comm.getSiteRoot()+"s/"+sl_uuid;
					//如果已存在分享文件和密码
					var view = { link: link,password:data.password,share_name:that.name,file_len:that.uuidArr.length,more:that.uuidArr.length>1?"等":""};
					//console.log(tmpl);
					var renderedPage = Mustache.to_html(tmpl, view);
					that.glable_mask= new Glable_mask();
					that.glable_mask.add($(renderedPage),true,function(){
						if(that.addProcess)
						{
							that.addProcess.abort();
						}
					});
					that.glable_mask.update();
					if(comm.lessThenIE(9) && comm.isIE()){
						$("#copy_share").find(".title").css("border-bottom","1px solid #c9c9c9");
					}

					/*var mail_cnt = '';
					var share_name = that.name;
					if(that.uuidArr != null){
						var len = that.uuidArr.length;
						mail_cnt = '我通过易控给你分享了“<div class="share-filename" title="'+that.name+'">'+that.name+'</div>”';
						if(len > 1){
							mail_cnt += '等';
							share_name += '等';
						}
						mail_cnt += len + '个文件（夹），查看链接';
					}

					$("#share_content").val(link);
					$("#j_mail_cnt").html(mail_cnt + link);*/

					/*$("#copy_share").off();
					$("#copy_share").on("click",".close",function (e){
						comm.stopEvent(e);
						that.glable_mask.remove();
						that.glable_mask = null;

					});*/

					$("#share_content_text").select();
					$("#share_content_text").on("click",function(e){
						comm.stopEvent(e);
						$(this).select();
					});

					$("#share_content_text").on("mouseenter",function(e){
						comm.stopEvent(e);
						$(this).select();
					});


					var copy_share_id;
					var copyObj = $("#share_content")[0];
					copyObj.oncopy = function(e){
						comm.stopEvent(e);
						if(copy_share_id != undefined){
							clearTimeout(copy_share_id);
						}
						copy_share_id = setTimeout(afterCopy,300);
					}
					function afterCopy(){
						that.add(sl_uuid);
					}

					var $share_pwd = $('#j_share_pwd');
					var okBtn = $("#copy_share").find(".ok");
					window.setClipboardContent=function(){
						okBtn.attr('data-clipboard-text',$("#share_content").text());
						$("#share_content_text").val($("#share_content").text());
					}

					//设置分享密码
					window.setSharePwd = function (obj, rStr) {
						obj.hide();
						$share_pwd.find('input.share-pwd').val(rStr);
						$share_pwd.find('#share_pwd').text(rStr);
						$share_pwd.find('input.is-share-pwd').val('on');
						$share_pwd.show();

						if(!okBtn.hasClass("unavailable")){
							okBtn.text('复制链接和密码');
							okBtn.width(87);
						}
						//var new_val = link + ' (密码:' + rStr + ')';
						//$("#share_content").val(new_val);
						//$("#j_mail_cnt").html(mail_cnt + new_val);
						$(".share-password").each(function(){
							$(this).html("（密码："+rStr+"）");
						});
						setClipboardContent();
					}
					//设置查阅密码
					$('#j_set_share_pwd').on('click', function(){

						//me.hide();
						var loadingBox = $("#j_share_loading");
						if(loadingBox.is(":visible")){
							return false;
						}
						loadingBox.show();
						var rStr = randomString(4);
						var me = $(this);
						$.post("/share/set_password",{share_id:data.share_id,password:rStr},function(ret){
							loadingBox.hide();
							if(ret.success){
								setSharePwd(me, rStr);
							}else{
								site_tip.setContent(ret.message,false,true);
							}
						},"json");

					});

					//默认已有密码
					if (data.password) {
						setSharePwd($('#j_set_share_pwd'), data.password);
					}



					//删除查阅密码
					$('#j_deletesharepwd').on('click', function(){
						var me = $(this);
						var loadingBox = $("#j_share_loading");
						if(loadingBox.is(":visible")){
							return false;
						}
						loadingBox.show();
						me.hide();
						$.post("/share/set_password",{share_id:data.share_id,password:""},function(ret){
							loadingBox.hide();
							me.show();
							if(ret.success){
								$share_pwd.find('input').val('');
								$share_pwd.find('#share_pwd').text('');
								$share_pwd.find('input.is-share-pwd').val('off');
								$share_pwd.hide();
								$('#j_set_share_pwd').show();
								$('#copy_share').find('.error').text('');
								if(!okBtn.hasClass("unavailable")){
									okBtn.text('复制链接');
									okBtn.width(51);
								}
								$(".share-password").each(function(){
									$(this).empty();
								});
								//$("#share_content").val(link);
								//$("#j_mail_cnt").html(mail_cnt + link);
								setClipboardContent();
							}else{
								site_tip.setContent(ret.message,false,true);
							}
						},"json");
					});

					//输入密码处理
					$share_pwd.find('input.share-pwd').on('keyup', function(){
						var reg = /[^A-Za-z0-9]/g;
						var val = $(this).val();
						if(reg.test(val) && val != '') {
							$(this).val(val.replace(reg, ''));
						}
					});
					$share_pwd.find('input.share-pwd').bind('change input', function(){
						var val = $(this).val();
						if(val.length < 4){
							var errorText = '密码不足四位';
							$('#copy_share').find('.error').text(errorText);
						} else {
							$('#copy_share').find('.error').text('');
							//var new_val = link + ' (密码:' + val + ')';
							//$("#share_content").val(new_val);
							//$("#j_mail_cnt").html(mail_cnt + new_val);
							$(".share-password").each(function(){
								$(this).html("（密码："+val+"）");
							});
							setClipboardContent();
						}
					});


					setClipboardContent();

					//输入mail
					var placeholder = $('#j_write_mail').attr('placeholder');
					var wBox = $('#j_mail_input').outerWidth();
					var historyMail = [];
					var isGet = 0;
					$('#j_write_mail').on({
						'keyup' : function(event){
							//方向键不需要发送
							if(event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40){
								return false;
							}

							if(val != ''){
								var val = $(this).val();
								check_email('#j_write_mail', event);
								/*
								 var wInput = $(this).width();
								 var leng = Compute(val);
								 if(leng.w > wInput){
								 $('#j_write_mail').width(wBox);
								 }
								 */
								if(event.keyCode==8){
									inputLength();
								}
								if(event.keyCode!=32 && event.keyCode!=13){
									//查找常用邮箱
									findMail(val, historyMail);
								}

							} else {
								searchTiptsHide();
							}
						},
						'blur' : function(event){

						},
						'keydown' : function(event){
							if(event.keyCode == 229 || event.keyCode==186 || event.keyCode==188 || event.keyCode == 13 || event.keyCode == 38 || event.keyCode == 40){
								event.preventDefault();
							}
							var val = $(this).val();
							if(event && (event.keyCode==8)){
								if(val == ''){
									if($('#j_write_mail').data('edit') != 1){
										$('#j_mail_input').find('li').last().remove();
									}
								}
								inputLength();
								if($('#j_mail_input').find('.close-icon').size() == 0){
									$('#j_write_mail').attr('placeholder', placeholder).css('width','100%');
								}
							}
						},
						'focus' : function(){
							//取得用户常用邮箱
							if(historyMail.length == 0 && isGet == 0){
								isGet = 1;
								$.get('/share/get_history_email', function(result){
									if(result.ret == -1){
										var len = result.data.length;
										for(i = 0; i < len; i++){
											historyMail.push(result.data[i]);
										}
									}
								}, 'json');
							}
						}
					});

					//选择提示的搜索词
					$("#j_history_box").on('click', 'li', function(e){

						e.stopPropagation();
						var val = $(this).text();
						$("#j_write_mail").val(val);
						isEmail('#j_write_mail', val);
						return false;
					});

					$('#copy_share, #glable_mask').click(function(e){
						var e = e || window.event; //浏览器兼容性
						var elem = e.target || e.srcElement;
						while (elem) { //循环判断至跟节点，防止点击的是div子元素
							if (elem.id && (elem.id=='j_write_mail' || elem.id=='j_history_box')) {
								return;
							}
							elem = elem.parentNode;
						}
						check_email('#j_write_mail');
						searchTiptsHide(); //点击的不是div或其子元素
					});

					function searchTiptsShow(){
						//按上下键时
						var $searchTipsLi = $('#j_history_box li');
						var size = $searchTipsLi.size();
						var downCount = 0;
						$(document).on('keydown', function(event){
							if(event.keyCode == 38){//向上
								downCount--;
								if(downCount < 0) {
									downCount = size;
								}
							}else if (event.keyCode == 40){ //向下
								downCount++;
								if(downCount > size) {
									downCount = 1;
								}
							} else {
								return;
							}

							var $searchTipsLiEq = $searchTipsLi.eq(downCount - 1);
							$searchTipsLiEq.siblings().removeClass('active')
							$searchTipsLiEq.addClass('active');
							$("#j_write_mail").val($searchTipsLiEq.find('a').text());
						});
					}

					function searchTiptsHide(){
						var val = $('#j_write_mail').val();
						if(val == ''){
							$('#j_history_box').html('');
						}
						$('#j_history_box').hide();
						$(document).unbind('keydown');//移除键盘事件
					}

					function findMail(val, historyMail){
						var len = val.length;
						var num = historyMail.length;
						if(len == 0 || num == 0){
							$('#j_history_box').html('').hide();
							return;
						}
						var html = '';
						for(var i = 0; i < num; i++){
							if(historyMail[i].substr(0, len)==val){
								html += '<li><a href="javascript:void(0);">'+historyMail[i]+'</a></li>';
							}
						}
						if(html == ''){
							$('#j_history_box').html('').hide();
							searchTiptsHide();
						} else {
							$('#j_history_box').html(html).show();
							searchTiptsShow();
						}
					}

					function Compute(v) {
						var d = document.getElementById('js_share_content');
						d.innerHTML = v;
						return { w: d.offsetWidth, h: d.offsetHeight };
					}

					$('#j_mail_input').click(function(){
						$('#j_write_mail').focus();
					});

					function check_email(that, e){
						var maxCount = 5;  //最多可分享的数量
						var val = $(that).val();
						val = val.replace(/\s/g, "");
						if(val == '' || val=='请输入邮箱，用空格分隔（一次最多5人）'){
							return;
						}

						if(arguments[1]){
							if(e && (e.keyCode==32 || e.keyCode==13 || e.keyCode == 229 || e.keyCode==186 || e.keyCode==188)){
								//正确的数量，不得超过5条
								var succ_list = $('#j_mail_input').find('li.succ-li');
								console.log(succ_list.length)
								if (succ_list.length == maxCount) {

									try{
										clearTimeout(time);
									}catch(e){}
									$('#j_mail_error').html('一次最多可分享5人');
									time = setTimeout(function(){
										$('#j_mail_error').html('');
										clearTimeout(time);
									}, 5000);

									return;
								}
								isEmail(that, val);
							}
						} else {
							console.log("c");
							isEmail(that, val);
						}
					}

					function isEmail(that, val){
						//var reg = /\w@\w*\.\w/;
						//var reg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,10})$/;
						var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
						var dom = '';
						if(reg.test(val)){
							//格式正确

							//判断有无重复
							var m = '';
							var isRe = false;
							$('#j_mail_input').find('li.succ-li').each(function(){
								m = $(this).find('span').text();
								if(val == m){
									isRe = true;
									return;
								}
							});
							if(isRe){
								$(that).val('');
								searchTiptsHide();
								return;
							}
							dom = '<li class="succ-li"><i class="share-icons sm-mail-icon"></i><span class="val">'+ val +'</span><i class="share-icons close-icon"></i></li>';

						} else {
							dom = '<li class="err-li"><span class="val">'+ val +'</span><i class="share-icons close-icon"></i></li>';
							try{
								clearTimeout(time);
							}catch(e){}
							$('#j_mail_error').html('该邮箱不合法');
							time = setTimeout(function(){
								$('#j_mail_error').html('');
								clearTimeout(time);
							}, 5000);
						}
						if($('#j_write_mail').data('edit') != 1){
							$('#j_mail_input').find('.mail-list').append(dom);
						} else {
							$('#j_write_mail').before(dom).data('edit', 0);
							var clone = $('#j_write_mail').clone(true);
							$('#j_write_mail').remove();
							$('#j_mail_input').append(clone);
							$('#j_write_mail').focus().css({'width':'346px'});
						}
						$(that).attr('placeholder', '');
						$(that).val('');
						inputLength();
						searchTiptsHide();
					}

					function inputLength(){
						return;
						var wBox = $('#j_mail_input').width();
						var wList = 0;
						$('#j_mail_input').find('li').each(function(){
							wList += $(this).outerWidth()+3;
						});
						var w  = 0;
						if(wBox > wList){
							w = wBox - wList - 3;
						} else {
							w = wBox;
						}
						if(w > 0){
							$('#j_write_mail').width(wBox);
						} else {
							$('#j_write_mail').width(wBox);
						}
					}

					$('#j_share_ps').on({
						'keyup': function(){
							var val = $(this).val();
							if(val.length >= 101){
								$(this).val(val.substr(0, 100));
							}
						}
					});


					$('#j_share_ps').placeholder();
					$('#j_write_mail').placeholder();

					//关闭
					$('#j_mail_input').on('click', '.close-icon', function(){
						$(this).parent().remove();
						if($('#j_mail_input').find('.close-icon').size() == 0){
							$('#j_write_mail').attr('placeholder', placeholder).css('width','100%');
						}
					});

					//编辑
					$('#j_mail_input').on('click', '.val', function(e){
						if($('#j_write_mail').data('edit') == 1){
							check_email('#j_write_mail');
						}
						var val = $(this).text();
						var width = $(this).parent().outerWidth()+2;
						var clone =  $('#j_write_mail').clone(true);
						$('#j_write_mail').remove();
						$(this).parents('li').first().before(clone).remove();
						$('#j_write_mail').focus().val(val).data('edit', 1).css({'width':width, 'min-width':'150px'});
						e.stopPropagation();
					});

					$('#j_share_send_btn').on('click', function(){
						//取到正确的mail
						check_email('#j_write_mail');
						var mails = '';
						var m = '';
						$('#j_mail_input').find('li.succ-li').each(function(){
							m = $(this).find('span').text();
							if(mails != ''){
								mails += ',';
							}
							mails += m;
						});
						if(mails == ''){
							try{
								clearTimeout(time);
							}catch(e){}
							$('#j_mail_error').html('收件人不允许为空');
							time = setTimeout(function(){
								$('#j_mail_error').html('');
								clearTimeout(time);
							}, 5000);
							return;
						}
						var content = $('#j_mail_cnt').text();
						var ps = $('#j_share_ps').val();
						var pwd = $('#j_share_pwd').find('.share-pwd').val();
						if(ps == '添加附言（100字以内）'){
							ps = '';
						}
						//slist:that.uuidArr,uuid:sl_uuid,name:this.name,pwd:pwd
						var data = {
							'mails'    : mails,
							//'content'  : content, //内容
							'ps'       : ps,
							'sl_uuid'  : sl_uuid,
							'share_name': that.name,
							'pwd'      : pwd,
							//添加分享链接的参数
							'slist':that.uuidArr,
							'uuid':sl_uuid,
							'name':that.name
						};
						//链接加进数据库
						//that.add(sl_uuid, 1);
						that.send_email(sl_uuid, data);
					});


					//没有安装flash或者flash版本低时，显示帮助
					if(!fls.f || fls.v < 10 ){
						/*if(comm.isIE()){
						 that.ieClipboard(sl_uuid);
						 return;
						 }
						 okBtn.addClass("unavailable");
						 okBtn.text("");
						 $("#copy_share").find(".err").css("display","block");

						 return;*/
						okBtn.qtip({
							content: '不能自动复制，请使用“Ctrl+C”或者右键“复制”链接地址到剪贴板',
							position:{
								at: 'top center',
								my:'bottom center'
							},
							show: {
								event:'click',
								effect: false
							},
							hide: {
								event:'unfocus',
								effect: false
							}
						});
					}
					else{
						var clipUrl = "clipboard";
						if(comm.lessThenIE(9) && comm.isIE()){
							clipUrl = "clipboardLess";
						}

						require([clipUrl],function(ZeroClipboard){
							ZeroClipboard.config( {
								moviePath : '/static/clipboard/ZeroClipboard.swf'
							});
							var client = new ZeroClipboard(okBtn);
							client.on('ready', function(readyEvent ) {
								client.on('aftercopy', function(event, args) {
									that.add(sl_uuid);

								});
								client.on('error', function(event, args) {
									ZeroClipboard.destroy();
									okBtn.addClass("unavailable");
									okBtn.text("");
									$("#copy_share").find(".err").css("display","block");
								});
							});
						});
					}

					/*分享类型切换*/
					$('#j_share_type').find('li').on('click', function(){
						var index = $(this).index();
						$(this).addClass('active').siblings().removeClass('active');
						$('#j_share_cnt').find('.cnt').eq(index).show().siblings().hide();
					});

					var contentPre = "我通过易控分享了“"+view.share_name+"”"+view.more+view.file_len+"个文件（夹）"+(view.password?"，密码是"+view.password:"")+"，大伙赶紧戳，手慢看不到哦！";
					/*var iconList = {
						"ppt": ["ppt","pptx"],
						"txt":["txt"],
						"excel":["xls","xlsx"],
						"word":["doc","docx"],
						"pic":["jpg","jpeg","png","bmp","ico"],
						"psd":["psd"],
						"ai":["ai"],
						"cad":["cad"],
						"cdr":["cdr"],
						"audio":["mp3","wav","wma","flac"],
						"video":["mp4","3gp","rmvb","mpg","avi"]
					};*/
					//console.log(that);
					var pic = location.origin+"/static/img/share_logo.jpg";

					var pf = $(this).data("platform");
					if ((pf != 'weibo') || (pf != 'tencentweibo')) {
						contentPre += view.link;
					}

					mobShare.config( {
						debug: false, // 开启调试，将在浏览器的控制台输出调试信息
						appkey: 'c6dd59c38b2a'
					});
					$(".share-sdk a").bind("click",function(){
						var platform = $(this).data("platform");
						var sdk = mobShare(platform);
						if(sdk){
							var title = platform =="qq"?"嗨":"给大家分享点干货，别乱传";
							var content = platform =="qq"?"我通过易控安全分享给你发送了一个神秘文件，赶紧戳，手慢看不到哦！":contentPre;
							if(platform=="tencentweibo"||platform=="weibo"||platform=="qzone"){
								pic = location.origin+"/static/img/share_logo_tencent.jpg";
							}else if(platform=="qq"){
								pic = location.origin+"/static/img/share_logo_message.png";
							} else if(platform=="douban") {
								pic = location.origin+"/static/img/share_logo_douban.jpg";
							}

							var share_url = view.link+"?platform="+platform;

							if ((document.location.protocol == 'https:') &&
								(platform == 'tencentweibo')) {
								pic = '';
							}

							mobShare.config( {
								params: {
									url: share_url, // 分享链接
									title: title, // 分享标题
									description: content, // 分享内容
									pic:pic
								}
							});

							sdk.send();
						}
					});
					//$("#share_sdk").show().appendTo($("#copy_share_box"));
				}
				else
				{
					//var site_tip = new Site_tip();
					site_tip.setContent(data.message,true,false);
					that.glable_mask.remove();
					if(data.error_code==7100 || data.error_code==7001)
					{
						require(["folder/main"],function(Folder){
							new Folder().reload();
						});
					}
				}
			},
			error:function(e){
				comm.ajaxErrorCommon(e);
				that.glable_mask.remove();
			}
		});

		return false;
	}
	
	
	Copy_share.prototype.add = function (sl_uuid, type){
		var btn = $("#copy_share button.ok");
		//console.log(btn.prop("disabled"));
		if(btn.length<=0 || btn.prop("disabled"))
		{
			return false;
		}
		var isSet = $('#j_share_pwd .is-share-pwd').val();
		var pwd = '';
		var type = arguments[1] || 0;
		
		if(isSet == 'on'){
			pwd = $('#j_share_pwd .share-pwd').val();
			if(pwd.length < 4){
				return;
			}	
		}
		var that = this;
		that.glable_mask.remove();
		that.glable_mask = null;
		site_tip.setContent("已复制",false,true);
		//
		/*btn.attr("disabled",true).text("保存中...");
		that.addProcess = $.ajax({
			url:"/share/add",
			method:"post",
			dataType:"json",
			data:{slist:this.uuidArr,uuid:sl_uuid,name:this.name,pwd:pwd},
			success:function(jsonData)
			{
				if(jsonData.ret == -1){
					if(type == 0){
						that.glable_mask.remove();
						that.glable_mask = null;
						//var site_tip = new Site_tip();
						site_tip.setContent("已复制",false,true);
					}
				}
				else
				{
					//var site_tip = new Site_tip();
					site_tip.setContent("分享失败，请重试!",false,true);
					btn.attr("disabled",false).text("复制链接");
				}
			},
			error:function(e)
			{
				comm.ajaxErrorCommon(e);
				btn.attr("disabled",false).text("复制链接");
			}
		});*/

		return false;
	}
	
	Copy_share.prototype.send_email = function (sl_uuid, data){
		var send_btn = $('#j_share_send_btn');
		if(send_btn.length<=0 || send_btn.prop("disabled"))
		{
			return;
		}
		var that = this;
		var arr = data.mails.split(',');
		var len = arr.length;
		send_btn.attr("disabled",true).html('正在发送...');
		//发送email
		$.ajax({
			type : 'post',
			url : '/share/send_email',
			data : data,
			dataType : 'json',
			success: function(result){
				//var site_tip = new Site_tip();
				send_btn.attr("disabled",false).html('发送');
				if(result.ret == -1){
					that.glable_mask.remove();
					that.glable_mask = null;

					site_tip.setContent("已与"+len+"人邮件分享",false,true);
				}
				else
				{
					site_tip.setContent("分享失败",true);
				}
			},
			error:function(e)
			{
				comm.ajaxErrorCommon(e);
				send_btn.attr("disabled",false).html('发送');
			}
		});
		return false;
	}
	
	
	Copy_share.prototype.ieClipboard = function (sl_uuid){
		var that = this;
		var cItem = $("#copy_share").find(".ok");
		cItem.off("click");
		cItem.on("click",function(e){
			comm.stopEvent(e);
			var flag = comm.copyToClipboard(cItem.attr("data-clipboard-text"));
			if(flag){
				that.add(sl_uuid);
				return true;
			}
			return false;
			
		});
		
	}

	
	/**
	 * 生成随机字符串
	 * 
	 * @returns {String}
	 */
	function randomString(len) {
	  len = len || 32;
	  var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
	  var maxPos = $chars.length;
	  var pwd = '';
	  for (i = 0; i < len; i++) {
	    pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
	  }
	  return pwd;
	}
	
	
	return Copy_share;
});